package adminYoga

import (
	"duoke/model/yogaModel"
	yogaService "duoke/service/yoga"
	"duoke/utils/response"
	"duoke/utils/valid"
	"github.com/gin-gonic/gin"
	"github.com/go-playground/validator/v10"
)

var Order = new(orderCtl)

type orderCtl struct{}

// Order 这个是课程订单
func (ctl *orderCtl) Order(c *gin.Context) {
	var req yogaModel.SearchOrder
	if err := c.ShouldBind(&req); err != nil {
		response.Error(c, valid.GetError(err.(validator.ValidationErrors), req), nil)
		return
	}
	list, err := yogaService.Order.List(c, &req)
	if err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	response.Success(c, "成功", list)
}

// CourseOrder 班课订单
func (ctl *orderCtl) CourseOrder(c *gin.Context) {
	var req yogaModel.SearchOrder
	if err := c.ShouldBind(&req); err != nil {
		response.Error(c, valid.GetError(err.(validator.ValidationErrors), req), nil)
		return
	}
	list, err := yogaService.Order.CourseOrder(c, &req)
	if err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	response.Success(c, "成功", list)
}
